package com.ruoyi.dynamic.controller.app;


import com.ruoyi.common.core.annotation.NoRepeatSubmit;
import com.ruoyi.common.core.constant.constant.PathConstant;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.common.core.pojo.vo.BaseVO;
import com.ruoyi.common.core.pojo.vo.MultiVO;
import com.ruoyi.common.core.pojo.vo.SingleVO;
import com.ruoyi.common.core.result.Result;
import com.ruoyi.dynamic.model.pojo.request.app.*;
import com.ruoyi.dynamic.model.pojo.result.app.AppRoomGameSelResult;
import com.ruoyi.dynamic.model.pojo.result.app.AppRoomHeartSelResult;
import com.ruoyi.dynamic.model.pojo.result.app.AppRoomHeatResult;
import com.ruoyi.dynamic.service.IRoomHeartService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "App-房间心动交友相关", description = "App-房间心动交友相关")
@RestController
@RequestMapping(PathConstant.APP_PATH + "room-heart")
public class AppRoomHeartController {

    private final IRoomHeartService iRoomHeartService;

    public AppRoomHeartController(IRoomHeartService iRoomHeartService) {
        this.iRoomHeartService = iRoomHeartService;
    }


    @Operation(summary = "主持获取当前活动状态 1自我介绍2自由发言3心动选择4自由发言5结果公布6结束", description = "开启心动交友游戏 1自我介绍2自由发言3心动选择4自由发言5结果公布6结束")
    @PostMapping("findStatus")
    public SingleVO<AppRoomHeatResult> findStatus(@RequestBody @Validated AppRoomHeartGetRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        AppRoomHeatResult id = iRoomHeartService.findStatus(request, userId);
        return Result.single(id);
    }

    @Operation(summary = "开启心动交友游戏", description = "开启心动交友游戏")
    @PostMapping
    public SingleVO<Long> openGame(@RequestBody @Validated AppRoomHeartCreateRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        Long id = iRoomHeartService.openGame(request, userId);
        return Result.single(id);
    }

    @Operation(summary = "开始发言", description = "开始发言")
    @PostMapping("startSay")
    public BaseVO startSay(@RequestBody @Validated AppRoomWishCloseRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean id = iRoomHeartService.startSay(request, userId);
        return Result.single(id);
    }

    @Operation(summary = "结束发言", description = "结束发言")
    @PostMapping("overSay")
    public BaseVO overSay(@RequestBody @Validated AppRoomWishCloseRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean id = iRoomHeartService.overSay(request, userId);
        return Result.single(id);
    }

    @Operation(summary = "选择心动人", description = "选择心动人")
    @PostMapping("selectHeart")
    public BaseVO selectHeart(@RequestBody @Validated AppRoomSelectHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        boolean id = iRoomHeartService.selectHeart(request, userId);
        return Result.single(id);
    }

    @Operation(summary = "查询我的选择结果", description = "查询我的选择结果")
    @PostMapping("selResult")
    public SingleVO<AppRoomHeartSelResult> selResult(@RequestBody @Validated AppRoomSelectHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        return Result.single(iRoomHeartService.selResult(request, userId));
    }

    @Operation(summary = "主播公布交友结果", description = "主播公布交友结果")
    @PostMapping("pubResult")
    public SingleVO<AppRoomHeartSelResult> pubResult(@RequestBody @Validated AppRoomPubHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        return Result.single(iRoomHeartService.pubResult(request, userId));
    }

    @NoRepeatSubmit
    @Operation(summary = "主播结束交友游戏", description = "主播结束交友游戏")
    @PostMapping("over")
    public BaseVO over(@RequestBody @Validated AppRoomPubHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        iRoomHeartService.over(request, userId);
        return Result.success();
    }


    @Operation(summary = "获取当前游戏结果", description = "获取当前游戏结果")
    @GetMapping("getResult")
    public MultiVO<AppRoomGameSelResult> getResult(AppRoomHeartGetRequest request) {
        return Result.multi(iRoomHeartService.getResult(request));
    }


    @Operation(summary = "自我介绍完下一步自由发言", description = "自我介绍完下一步自由发言")
    @PostMapping("introOver")
    public BaseVO introOver(@RequestBody @Validated AppRoomPubHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        iRoomHeartService.introOver(request, userId);
        return Result.success();
    }


    @Operation(summary = "自由发言结束开始心动选择", description = "自由发言结束开始心动选择")
    @PostMapping("makeOver")
    public BaseVO makeOver(@RequestBody @Validated AppRoomPubHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        iRoomHeartService.makeOver(request, userId);
        return Result.success();
    }


    @Operation(summary = "心动选择结束开始自由发言", description = "心动选择结束开始自由发言")
    @PostMapping("selOver")
    public BaseVO selOver(@RequestBody @Validated AppRoomPubHeartRequest request) {
        Long userId = SecurityContextHolder.getUserId();
        iRoomHeartService.selOver(request, userId);
        return Result.success();
    }


}

